<%@ page contentType="text/html;charset=UTF-8" language="java"%>
<%@ include file="/WEB-INF/jsp/common/_includes.jsp" %>
<jsp:include page="/WEB-INF/jsp/common/_head.jsp"></jsp:include>
<div class="ui grid">
	<div class="row">
		<div class="column">
			<div class="ui two column grid">
				<div class="three wide column">
					<jsp:include page="/WEB-INF/jsp/common/_sidebar.jsp">
						<jsp:param name="index" value="5"/>
					</jsp:include>
				</div>
				<div id="container" class="thirteen wide column">
					<div class="alert alert-success w200 center-block text-center " style="display: none; " role="alert"></div>
					<ol class="breadcrumb">
						<li><a href="/">后台管理</a></li>
						<li><a href="/answer">答案管理</a></li>
						<li class="active">录入答案</li>
					</ol>
					<form class="form-horizontal" id="from" method="post" action="/managers/add">
						<div class="form-group">
							<label class="col-sm-3 control-label">姓名</label>
							<div class="col-sm-5 desc">
								<input type="text" class="form-control" id="exampleInputEmail1" name="userName" placeholder="输入管理员姓名">
							</div>
						</div>
						<div class="form-group">
							<div class="col-sm-offset-3 col-sm-2">
								<button type="submit" class="btn btn-success">提交</button>
							</div>
						</div>
					</form>
				</div>
			</div>
		</div>
	</div>
</div>
<jsp:include page="/WEB-INF/jsp/common/_foot.jsp"></jsp:include>
<script type="text/javascript" src="/static/vendor/jquery.validate/jquery.validate.js"></script>
<script type="text/javascript" src="/static/js/support/detail.js"></script>
<script type="text/javascript">
	$(function(){
		$('.avatar-box').on('mouseenter', function(){
			$('.avatar-edit').css({display: 'block'});
		}).on('mouseleave', function(){
			$('.avatar-edit').css({display: 'none'});
		});
		$("form").validate({
			rules: {
				userName: {
					required: true
				}
			},
			messages: {
				userName: {
					required: "请输入管理员名称"
				}
			},
			submitHandler:function(form){
				$.post(form.action,$(form).serialize(),
						function(data,status){
							if(data.status == 'ok'){
								var info ="创建管理员成功，登录密码为:"+data.password;
								success(info);
								setTimeout(
										function(){
											window.location.href="/managers/details/"+data.userCode+"?password="+data.password
										},5000);
							}else{
								$(".alert-warning").text(data.message).fadeIn(1000);
								setTimeout(function(){
									$(".alert-warning").fadeOut(1000);
								},3000);
							}
						});
			}
		});

	});
</script>